//index.vue
<template>
  <div>
    <h1 class="logo">cnodejs Api Test</h1>
    <router-link to="/content">{{'跳转到content'}}</router-link>
    <router-link to="/user">{{'跳转到user'}}</router-link>
    <router-link to="/nested">{{'跳转到nested'}}</router-link>
    <router-link :to="{ name:'user', params: { id: 'id'}}">{{'跳转到user'}}</router-link>
    <ul class="list">
      <li v-for="item in lists" v-text="item.title"></li>
    </ul>
  </div>
</template>
<script>
export default {
  data() {
    return {
      lists:[]
    }
  },
  created () {
    // 组件创建完后获取数据，这里和1.0不一样，改成了这个样子
    this.get_data()
  },
  methods: {
    get_data: function(params) {
      let v = this
      if (!params) params = {}
      // 我们这里用全局绑定的 $api 方法来获取数据，方便吧~
      // debugger
      this.$api.get('topics', params, function(r) {
        v.lists = r.data
      })
    },
  },
}
</script>
<style  rel="stylesheet/scss" lang="scss">
	@import "../style/style.scss"
</style>